1. Field of the Invention
The present invention relates to an image coding apparatus that encodes a moving picture with high efficiency, and particularly to an image coding apparatus and an image coding program that execute a quantization control so that a generating bit is made close to a target bit.
2. Description of the Related Art
As a method of encoding data of a moving picture such as a television signal with high efficiency for recording or transmission, an encoding system such as a Moving Picture Experts Group (MPEG) system has been designed. As for the ISO standard of MPEG, coding methods such as the MPEG-1 standard, the MPEG-2 standard, the MPEG-4 standard are employed. In addition, as a system for further improving a compression ratio, the H.264/AVC (Advanced Video Coding) standard and the like have been specified.
In general, a method of encoding and compressing a moving picture employs a so-called hybrid coding method in which compression using a temporal correlation and compression using a spatial correlation are combined.
The compression using a temporal correlation utilizes a similarity (high correlation) between a previous picture and a subsequent picture. Specifically, in the case where there is no change between a previous frame and a current frame, no data is transmitted, or only a motion vector and residual data of portions that are most alike between the previous frame and the current frame are transmitted. By doing so, the data amount can be reduced. This is called the Motion Compensated Prediction.
On the other hand, the compression using a spatial correlation utilizes an approximation of values (high correlation) between adjacent pixels in a picture. Specifically, there is employed a method in which the Discrete Cosine Transform (DCT) is used to perform a frequency transform on a certain area unit in a picture.
A signal which has the image data redundancy removed by the Motion Compensated Prediction and the DCT is quantized so as to compress the data. The quantization is a process in which a DCT coefficient is divided by a quantization step value to be converted into a smaller value and then the quotient is rounded to an integer. With this process, values of high frequency components most of which have small values can be held down to 0, thus largely eliminating a generating bit.
In a conventional quantization control method, for example, a frame unit quantization control section determines quantization characteristics to be used in a current image frame based on the generated information quantity of a previous image frame. A block unit generated information quantity calculating section calculates the generated information quantity per one block from the generated information quantity accumulated up to the current time for the current image frame. A maximum allowable information quantity calculating section calculates maximum allowable information quantity per block every time when one block in the current image frame is encoded. A comparing section compares the generated information quantity per block with the maximum allowable information quantity every time when one block in the current image frame is encoded. Based on the comparison results, a block unit quantization control section determines quantization characteristics of the next block within a predetermined range around quantization characteristics determined at the frame unit quantization control section. Such an apparatus is disclosed in, for example, Japanese Patent Laid-open No. 2002-77905 A (Patent Reference 1).
According to the technology described in Patent Reference 1, a quantization step as a basis for the use of encoding an image frame or blocks constituting an image frame to be processed is determined on the basis of the generated bit that is the amount of data produced in encoding the previous image frame. That is, depending on a residual value between a predetermined target bit and a generated bit, a generating bit is controlled so as to be decreased by increasing a quantization parameter in the case where the generated bit is larger than the target bit. On the contrary, in the case where the generated bit is smaller than the target bit, a generating bit is controlled so as to be increased by decreasing the quantization parameter. Accordingly, a generating bit is controlled so as to be close to the target bit.